package com.example.kotlin_api.javadesign.observer

class ActSubject : Subject {
    private val setData: LinkedHashSet<IObserver> = linkedSetOf()

    override fun add(observer: IObserver) {
        setData.add(observer)
    }

    override fun del(observer: IObserver) {
        setData.remove(observer)
    }

    override fun notifyObservers() {
       /* for (item in setData) {
            item.update()
        }
        var ite = setData.iterator()
        while (ite.hasNext()) {
            ite.next().update()
        }*/
        setData.forEach { it.update() }
    }
}